Skip to content

fix: extract message from WASM SDK error objects in toError()#20

Merged
PastaPastaPasta merged 1 commit intoPastaPastaPasta:mainfrom
thephez:fix/parse-wasm-errors
Apr 13, 2026
Merged

fix: extract message from WASM SDK error objects in toError()#20
PastaPastaPasta merged 1 commit intoPastaPastaPasta:mainfrom
thephez:fix/parse-wasm-errors

Conversation

@thephez
Copy link
Copy Markdown
Contributor

@thephez thephez commented Apr 13, 2026

When the Dash SDK throws an error from a WASM-based operation, it throws a plain object with a message property rather than a standard JS Error instance. The toError() utility was falling through to String(value) for these, producing the unhelpful [object Object] shown in the UI error panel.

This fix adds a check for objects with a message property before the string fallback, so WASM SDK errors now display their actual human-readable message. The change covers all error paths in the app since every catch block routes through toError().

Changes

  • Updated toError() in src/ui/state.ts to extract message from non-Error objects before falling back to String(value)
  • Fixes ERR-1008 ("Send to address failed") and all other error codes that surface WASM SDK errors

Summary by CodeRabbit

  • Bug Fixes
    • Improved error message handling when exceptions are thrown as objects. The system now extracts human-readable messages from object-shaped errors while preserving existing Error instances, resulting in clearer error reporting.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ffad9eb7-e55d-49fb-92e3-0a0f27f684c9

📥 Commits

Reviewing files that changed from the base of the PR and between 8096cc6 and 84dd9b6.

📒 Files selected for processing (1)
  • src/ui/state.ts

📝 Walkthrough

Walkthrough

The toError function in src/ui/state.ts now extracts human-readable message fields from non-Error objects before converting them to strings, improving error message handling for object-shaped errors while preserving existing Error instances.

Changes

Cohort / File(s) Summary
Error Message Extraction
src/ui/state.ts
Enhanced toError function to check for and extract message property from non-Error objects, providing better error messaging for object-shaped exceptions while maintaining backward compatibility with stringified fallback.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A tiny function, quick and neat,
Extracts the message, makes errors sweet,
From objects tangled, messages freed,
Now errors speak just what we need! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: extracting messages from WASM SDK error objects in the toError() function, matching the primary focus of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thephez
Copy link
Copy Markdown
Contributor Author

thephez commented Apr 13, 2026

Before:
image

After:
image

@PastaPastaPasta PastaPastaPasta merged commit 1ef2478 into PastaPastaPasta:main Apr 13, 2026
3 checks passed
@thephez thephez deleted the fix/parse-wasm-errors branch April 13, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants